package cn.arnold.leetcode;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Arnold-Xiang
 * @Info 1
 * 1 2 +
 */
public class Calculator {
    public static void main(String[] args) {
       String s = "ABCDZJUDCBA";
        System.out.println(longestPalindrome(s));
        List<Number> numsber = new ArrayList<Number>();
        List<String> name = new ArrayList<>();
        name.add("icon");
        //fun(name);
        List<Integer> age = new ArrayList<>();
        age.add(18);
        fun(age);
        numsber.add(214);
        fun(numsber);

    }
    static public String longestPalindrome(String s) {
        int n = s.length();
        boolean[][] dp = new boolean[n][n];
        String ans = "";
        for (int l = 0; l < n; ++l) {
            for (int i = 0; i + l < n; ++i) {
                int j = i + l;
                if (l == 0) {
                    dp[i][j] = true;
                } else if (l == 1) {
                    dp[i][j] = (s.charAt(i) == s.charAt(j));
                } else {
                    dp[i][j] = (s.charAt(i) == s.charAt(j) && dp[i + 1][j - 1]);
                }
                if (dp[i][j] && l + 1 > ans.length()) {
                    ans = s.substring(i, i + l + 1);
                }
            }
        }
        return ans;
    }
    static void fun(List<? extends Number> data){
        System.out.println(data.get(0));
    }
}
